<template>
    <div class="content">
        
            <h2>新建工作票</h2>
        <div class="container">
             <p>
                 <span>任务单：</span>
                 <j-search-select-tag   v-model="redNum" :trigger-change="true" dictCode="" type="list" setFieldsValue="selectValue" :dictOptions="dictOptions" @change="chatl"> </j-search-select-tag>
             </p>
              <p>
                 <span>风场：</span>
                <j-select-depart placeholder="请选择单位名称" v-model="orgName" style="width:770px;" @change="chafan"/>
             </p>
              <p>
                 <span>工作内容：</span>
                <a-textarea
                    v-model="workDetail"
                    :auto-size="{ minRows: 3, maxRows: 5 }"
                    />
             </p>
             <p>
                  <a-button type="primary" class="ok" @click="add">
                    确定
                </a-button>
             </p>
        </div>
    </div>
</template>
<script>
  import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
  import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
  import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
  import { httpAction, getAction,postAction } from '@/api/manage'
export default {
     components: {
      JSearchSelectTag,
      JSelectDepart,
      JDictSelectTag,
    },
    data(){
        return{
            ticket_type:'',
            redNum:'',
            orgName:'',
            workDetail:'',
             dictOptions:[],
              url: {
          add: "/eleswitch/eleSwitch/add",
        },
       
        }
    },
    methods:{
        chatl(value){
            console.log('任务单1',this.redNum)
        },
       
        chafan(value){
            console.log('风场1',this.orgName)
        },
        add(){
            console.log('确定')
            var params = {
                rwdId:this.redNum,
                orgName:this.orgName,
                workDetail:this.workDetail,
            }
             postAction(this.url.add,params).then(res=>{
                console.log(res)
                if(res.success == true){
                    this.$message.success('添加成功！');
                    this.$router.push({
                        name:'operation_ticket-list-procedure-draft-OneElectricalList',
                        })
                }
            })
        }
    },
    mounted(){
        console.log(this.dictOptions)
        var params = {
            pageNo:1,
            pageSize:9999,
        }
        getAction('/tasklist/taskList/list?tacketCode=1',params).then(res=>{
                for(var i=0 ;i<res.result.records.length; i++){
                    console.log(i)
                     this.dictOptions.push({
                         text:res.result.records[i].taskContent,
                         value:res.result.records[i].rwdId
                })
                }
                
               
            })
    }
}
</script>
<style scoped>
    .content{
        width:1500px;
        height: 900px;
        background-color:#fff; 
       
    }
    h2{
       position: relative;
       top:50px;
       left:650px;
    }
    .container{
        width:800px;
        height:270px;
        border:3px solid #E8E8E8;
        border-radius: 5px;
        margin:100px 0px 0px 300px;
        padding:10px;
    }
    p{
        display: flex;
        justify-content: space-between;
    }
    span{
        display: inline-block;
        width:90px;
    }
    .ok{
        position: relative;
        left:700px;
        top:-5px;
       
    }
</style>